//
//  I_Statistics.m
//  YunDongAdmin
//
//  Created by lqq on 2018/9/14.
//  Copyright © 2018年 cloudfighting.com. All rights reserved.
//

#import "I_Statistics.h"

@implementation I_Statistics
/**
 工作室今日概况
 */
+ (NetworkTask *)requestGymOverviewIsCheckAll:(BOOL)isCheckAll onSuccess:(void(^)(M_GymOverview *gymOverview))successBlock failure:(ErrorBlock)failureBlock
{
    NSDictionary *criticalValue = nil;
    if (isCheckAll) {
        criticalValue = @{@"gymid":@""};
    }
    return [NET POST:@"/gym-api/admin/1.0.0/getGymOverview" parameters:nil criticalValue:criticalValue success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        M_GymOverview *gymOverview = [[M_GymOverview alloc] initWithDictionary:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
        if (successBlock) {
            successBlock(gymOverview);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}


/**
 统计会员数量
 */
+ (NetworkTask *)requestStatMemberIsCheckAll:(BOOL)isCheckAll onSuccess:(void(^)(M_StatMember *statMember))successBlock failure:(ErrorBlock)failureBlock
{
    NSDictionary *criticalValue = nil;
    if (isCheckAll) {
        criticalValue = @{@"gymid":@""};
    }
    return [NET POST:@"/gym-api/admin/1.0.0/statMember" parameters:nil criticalValue:criticalValue success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        M_StatMember *statMember = [[M_StatMember alloc] initWithDictionary:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
        if (successBlock) {
            successBlock(statMember);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}


/**
 当前最新记录的列表
 
 @param isCheckAll 是统计品牌还是单个门店
 @param type 统计类型
 @param date 日期
 */
+ (NetworkTask *)requestGymOverviewForMemberIsCheckAll:(BOOL)isCheckAll
                                  statisticsMemberType:(StatisticsMemberType)type
                                                  date:(NSDate *)date
                                               success:(void(^)(NSMutableArray *list))successBlock
                                               failure:(ErrorBlock)failureBlock
{
    NSDictionary *criticalValue = nil;
    if (isCheckAll) {
        criticalValue = @{@"gymid":@""};
    }
    return [NET POST:@"/gym-api/admin/2.0.0/listGymMemberDay" parameters:@{@"dataType":@(type)} criticalValue:criticalValue success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        NSMutableArray *list = [M_StatisticsMember arrayOfModelsFromDictionaries:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
        if (successBlock) {
            successBlock(list);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}
@end
